{php include wl_template('common/header');}
<!-- page 容器 -->
<div class="page">
  <!-- 标题栏 -->
  <header class="bar bar-nav">
    <a class="icon icon-me pull-left open-panel"></a>
    <h1 class="title">绑定柜门与课代表</h1>
  </header>
123
  <!-- 这里是页面内容区 -->
  <div class="content" name="main">
    <div class="content-block">设备信息ID：{$info_id}</div>
    <div class="content-block">设备名称<span style="color: red;">* </span>：{$device_name}</div>  
    <div class="content-block">柜门号<span style="color: red;">* </span>：{$door}</div>
    {if $already_name==false}
    <div class="content-block">姓名<span style="color: red;">* </span>：<input type="text" name="name" placeholder="您的姓名"></div>
    {else}
    <div class="content-block">姓名<span style="color: red;">* </span>：{$student_name}</div>
    {/if}
    <div class="content-block"> <input type="submit" value="绑定" openid="{$_W['openid']}"/></div>
  </div>
</div>

<!-- popup, panel 等放在这里 -->
<div class="panel-overlay"></div>
<script type="text/javascript">
function submit_check()
{
    if($("input[name='name']").length > 0){
         if(document.getElementsByName("name")[0].value.length ==0 )
        {
            alert("请输入您的姓名！");	
          return false;
        }
         else
         {
             var name = document.getElementsByName("name")[0].value;
             var re = /^[\u2E80-\u9FFF]+$/;
            if(!re.test(name)) {
                alert('姓名请输入汉字');
                //window.location.href=window.location.href;
                return false;
            } 
            return true;
        }    
    }
  
    return true;
}
	$(function(){
        $('input:submit').click(function() {
        console.log(1111);
            if(submit_check()){
                var openid = $(this).attr('openid'); 
                
                var device_name = "{php echo $device_name}";
                var info_id = "{php echo $info_id}";
                var door = "{php echo $door}";
                if($("input[name='name']").length > 0)
                    var name = $("input[name='name']").val();
                else
                    var name = "{php echo $student_name}";
                var postdata = {                   
                    device_name : device_name,
                    info_id : info_id,
                    door :door,
                    openid : openid,
                    name : name
                }; 
                //alert(JSON.stringify(postdata));
                $.post("{php echo app_url('scangenerate/scan/door_student_button');}", postdata ,function(data){ 
                     //alert(data); 
                     window.location="{php echo app_url('scangenerate/scan/prompt');}&prompt="+data;
                 });  
                              
            }           
		});

        
	});

</script>

{php include wl_template('common/footer');}
	